//
//  MIDIcommCell.m
//  迷笛
//
//  Created by . on 2018/9/20.
//  Copyright © 2018年 🍃🌺🌺🍃. All rights reserved.
//

#import "MIDIcommCell.h"

@implementation MIDIcommCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self addSubview:self.headimage];
        [self.headimage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_offset(WidthScale(16));
            make.left.mas_offset(WidthScale(16));
            make.width.mas_offset(WidthScale(40));
            make.height.mas_offset(kDevice_Is_iPhoneX?HeighX(40):HeightScale(40));
        }];
        [self addSubview:self.name];
        [self.name mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.headimage).offset(WidthScale(5));
            make.left.equalTo(self.headimage.mas_right).offset(WidthScale(10));
            [self.name setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
        }];
        [self addSubview:self.count];
        [self.count mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.name.mas_bottom).offset(WidthScale(10));
            make.left.equalTo(self.name);
            make.width.mas_offset(WidthScale(287));
//            make.bottom.mas_offset(WidthScale( -20));
        }];
        [self addSubview:self.time];
        [self.time mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.count.mas_bottom).offset(WidthScale(10));
            make.left.equalTo(self.name);
            [self.time setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
        }];
        [self addSubview:self.combtn];
        [self.combtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.time);
            make.right.mas_offset(WidthScale(-20));
            make.width.mas_offset(WidthScale(13));
            make.height.mas_offset(kDevice_Is_iPhoneX?HeighX(13):HeightScale(13));
            make.bottom.mas_offset(-20);
        }];
        
    }
    return self;
}
-(UIButton *)headimage
{
    if (!_headimage)
    {
        _headimage =[[UIButton alloc]init];
        _headimage.layer.masksToBounds = YES;
        
        [_headimage.layer setCornerRadius:WidthScale(20)]; //设置矩圆角半径
    }
    return _headimage;
}
-(UILabel *)name
{
    if (!_name)
    {
        _name =[[UILabel alloc]init];
        _name.textColor = [UIColor colorWithHexString:@"#FF005D"];
        _name.font =[UIFont systemFontOfSize:WidthScale(15)];
    }
    return _name;
}
-(UILabel *)count
{
    if (!_count)
    {
        _count =[[UILabel alloc]init];
        _count.textColor = [UIColor colorWithHexString:@"#FFFFFF"];
        _count.font =[UIFont systemFontOfSize:WidthScale(14)];
        _count.numberOfLines = 0;
        _count.lineBreakMode = NSLineBreakByWordWrapping;
        CGSize size = [_count sizeThatFits:CGSizeMake(WidthScale(287), MAXFLOAT)];//根据文字的长度返回一个最佳宽度和高度
        _count.frame = CGRectMake(0, 0, WidthScale(287), size.height);
    }
    return _count;
}
-(UILabel *)time
{
    if (!_time)
    {
        _time =[[UILabel alloc]init];
        _time.textColor = [UIColor colorWithHexString:@"#666666"];
        _time.font =[UIFont systemFontOfSize:WidthScale(10)];
    }
    return _time;
}
-(UIButton *)combtn
{
    if (!_combtn)
    {
        _combtn =[[UIButton alloc]init];
    }
    return _combtn;
}
@end
